<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<link rel="stylesheet" href="css/brand.css"></link>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>品牌管理页</title>
    <style type="text/css">
        table{
            width: 100%;
            border-collapse: collapse;
        }
        table td{
           border: 1px solid rgba(10,186,134,0.51);
           text-align: center;
        }
        /*#deleteBrandBtn,*/
        /*#addBrandBtn*/
        /*{*/
        /*    float: right;*/
        /*}*/
        .text-float{
            float: left;
        }
        /*  HTML5已不支持   border="1" cellspacing="0" width="800" */
    </style>
</head>
<body>
<h1 id="head">${LOGIN_USER.username},欢迎您
    <a href="${ctx}/logout" style="text-decoration: none">[注销]</a>
</h1>
<form class="text-float">
        状态：
    <select id="select1">
        <option class="statusId" id="qiyong" value="启用">启用</option>
        <option class="statusId" id="jinyong" value="禁用">禁用</option>
        <option class="statusId" id="quanbu" value="全部状态">全部状态</option>
    </select>
    品牌名称：<input type="text" id="guanjianzi" placeholder="请输入关键词" value="请输入关键字">
    <input type="button" value="查询" id="select">
    <input type="button" value="重置" id="re">
</form>

    <input type="button" value="新增" id="addBrandBtn">
    <input type="button" value="批量删除" id="deleteBrandBtn"><br>
<%--<hr>--%>
<table>
    <tr id="table-head">
        <th>选择</th>
        <th>序号</th>
        <th>品牌名称</th>
        <th>企业名称</th>
        <th>排序</th>
        <th>品牌介绍</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
        <c:forEach items="${pageBean.data}" var="brand">
           <tr>
               <td><input type="checkbox"></td>
               <td>${brand.id}</td>
               <td>${brand.brandName}</td>
               <td>${brand.companyName}</td>
               <td>${brand.ordered}</td>
               <td>${brand.description}</td>
               <td>
                   <c:if test="${brand.status == 1}">
                       启用
                   </c:if>
                   <c:if test="${brand.status == 0}">
                       禁用
                   </c:if>
               </td>
               <td><a href="${ctx}/toUpdate?id=${brand.id}">修改</a>
                   <a href="${ctx}/delete?id=${brand.id}" onclick="if(confirm('确定删除?')==false)return false;">删除</a>
               </td>
           </tr>
       </c:forEach>
</table>

<!-- 分页工具容器-->
<div class="page-container">
    <!-- 分页工具栏（pageBar）-->
    <jsp:include page="common/pageBar.jsp">
        <jsp:param name="url" value="/SelectAll" />
    </jsp:include>
</div> <!-- end of page-container -->

<div style="margin-top: 50px;" id="dqyh">
    <p>当前在线用户数：${applicationScope.OnlineCount}</p>
</div>

</body>

<script>
    function getContextPath() {
        var pathName = document.location.pathname;
        var index = pathName.substr(1).indexOf("/");
        var result = pathName.substr(0,index+1);
        return result;
    }

    let addBrandBtn = document.getElementById("addBrandBtn");
    //绑定点击事件
    addBrandBtn.onclick=function () {
        window.location.href=getContextPath() + "/addBrand.jsp"
    }

    var selects = document.getElementById("select1");
    selects.onchange = function () {
        var indexs = selects.selectedIndex;  //选中项的索引
        var statusvalue = selects.options[indexs].value+'';
        statusvalue.toString();
    }

</script>


</html>